<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>设置 - 会员中心 -  {:C('YTATA_SITE_NAME')}</title>
<link href="__ROOT__/{:C('YTATA_TPL_DIR')}/public/css/user.css" rel="stylesheet" type="text/css">
<include file="public:header" />
<div class="usermain">
  <div class="mleft">
<include file="left_nav" />
  </div>
  
  <div class="mright">
  
    
	
    <div class="mbox">
	  	<div class="utopt">
			  <div class="tit">账号设置</div>
			<include file="set_nav" />
			<div class="clear"></div>
	  </div>
	  
	  
        <div class="user_form_tit">
		<h2>基本</h2>
		</div>
		
		
        <div class="set_main">
		 <div class="fl">用户名:</div>
		<div class="fr">
		  <div class="txt substring" id="J_uname">{$user.username}</div>
		  
		  <div class="editbtn J_user_edit_username">点击修改</div>
		  <div class="clear"></div>
		</div>
		<div class="fl">手机号:</div>
		<div class="fr">
		  <div class="txt" id="J_umobile">{$user.mobile_txt|default="未填写手机号"}</div>
		   <div class="editbtn J_user_edit_mobile">点击修改</div>
		   <div class="clear"></div>
		</div>
		<div class="fl">我的擅长:</div>
		<div class="fr">
		  <div class="sp J_user_edit_sp">{$user.specialty|default="这家伙很懒，什么也没有留下！"}</div>
		   <div class="clear"></div>
		</div>
		<div class="clear"></div>
		</div>
		
		
		 <div class="user_form_tit">
		<h2>账号绑定</h2>
		</div>
		
		 <div class="set_binding">
		 
		 
		 
		
		
		 <volist name="oauth_list" id="oauth">
		 
		   <div class="list ">

			<eq name="oauth.is_bind" value="1">
					<a class="uu_api_login_btn {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}"></a>
				   <div class="apiname">{$oauth.name}已绑定 </div>
				    <a class="editbtn" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}">点击解绑</a>
		   <else/>
					<a class="uu_api_login_btn {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}"></a>
					<div class="apiname">{$oauth.name}未绑定 </div>
				   <a class="editbtn" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}">点击绑定</a>
		   </eq>
		   
		   <div class="clear"></div>
	      <eq name="oauth.is_bind" value="1"><div class="sign"></div></eq>
		   </div>
		   
		   </volist>
		   
		   
		   
		   
      </div>
	 
					
		
		
    </div>
	
	 
	
	
  </div>
   <div class="clear"></div>
</div>
<include file="public:footer" />

<script type="text/javascript">
$(document).ready(function()
{

$('.J_user_edit_username').live('click',function() {
		 var YTATADialog = $(this).dialog({
		        title: false,
        		loading: true,
				footer: false,
				header: false,
				border: false,
				backdrop: false
		});
		 $.getJSON(ajaxURL, { act: "ajax_edit_username"}, function(json){
					if (json.status==0){
						YTATADialog.hide();
						disapperTooltip("remind", json.content);
					}else if (json.status==1){
						YTATADialog.hide();
						var editDialog = $(this).dialog({
								title: "修改用户名",
								content:json.content,
								footer: true,
								header: true,
								border: true,
								innerPadding: true,
								backdrop: true,
								yes: function() {
									
									username=$('#ajax_edit_username_input').val()
										$.getJSON(ajaxURL, { act: "ajax_edit_username",username:username,edit:'1'}, function(json){
										if (json.status==0){
											disapperTooltip("remind", json.content);
										}else if (json.status==1){
											$('#J_uname').text(json.username);
 											disapperTooltip("success",json.content);
										}else{
											disapperTooltip("remind","修改失败，未知错误");
										}
								});
									
 	
									
							}
						});
					}else{
						YTATADialog.hide();
						disapperTooltip("remind","未知错误");
					}
		});
	});
	$('.J_user_edit_mobile').live('click',function() {
		 var YTATADialog = $(this).dialog({
		        title: false,
        		loading: true,
				footer: false,
				header: false,
				border: false,
				backdrop: false
		});
		 $.getJSON(ajaxURL, { act: "ajax_edit_mobile"}, function(json){
					if (json.status==0){
						YTATADialog.hide();
						disapperTooltip("remind", json.content);
					}else if (json.status==1){
						YTATADialog.hide();
						var MDialog = $(this).dialog({
								title: "修改手机号",
								content:json.content,
								footer: true,
								header: true,
								border: true,
								innerPadding: true,
								backdrop: true,
						 		yes: function() {
									
									mobile=$("input[name='mobile']").val();
									code=$("input[name='code']").val();
								$.getJSON(ajaxURL, { act: "ajax_edit_mobile",mobile:mobile,code:code,edit:"1"}, function(json){
										if (json.status==0){
											disapperTooltip("remind", json.content);
										}else if (json.status==1){
 											disapperTooltip("success",json.content);
											$('.J_umobile').text(json.mobile_hide);
											$('.modal').remove();
											$('.modal_backdrop').remove();
										}else{
											disapperTooltip("remind","修改失败，未知错误");
										}
								});	
							}
						});
						MDialog.setCloseDialog(false);
					}else{
						YTATADialog.hide();
						disapperTooltip("remind","未知错误");
					}
		});
	});
//发送验证码
		$('.J_send_code').live('click',function() {
					btn=$(this);
					if (btn.hasClass('btn_disabled')) return false;
					function settime(countdown) {
						if (countdown == 0) {
							btn.removeClass('btn_disabled');
							btn.text('获取验证码');
							countdown = {:C('YTATA_SMS_SETTIME')};
							return;
						} else {
							btn.addClass('btn_disabled');
							btn.text('重新发送' + countdown + '秒');
							countdown--;
						}
						setTimeout(function() {
							settime(countdown)
						},1000)
					}
					var mobile=$('input[name=mobile]').val();
					if (mobile.length!=11){
						disapperTooltip("remind",'请填写正确的手机号');
						return false;
					}
					btn.addClass('btn_disabled').html('正在发送中.');
					$.getJSON(ajaxURL, { act:"ajax_send_mobile_code",mobile:mobile,in_user:0}, function(json){
						if (json.status==0){
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}else if (json.status==1){
							disapperTooltip("success",json.content);
							settime({:C('YTATA_SMS_SETTIME')});
						}else{
							btn.removeClass('btn_disabled').html('获取验证码');
							disapperTooltip("remind",json.content);
						}
					});
		});



	$('.J_user_edit_sp').live('click',function() {
		 var YTATADialog = $(this).dialog({
		        title: false,
        		loading: true,
				footer: false,
				header: false,
				border: false,
				backdrop: false
		});
		 $.getJSON(ajaxURL, { act: "ajax_edit_sp"}, function(json){
					if (json.status==0){
						YTATADialog.hide();
						disapperTooltip("remind", json.content);
					}else if (json.status==1){
						YTATADialog.hide();
						var MDialog = $(this).dialog({
								title: "修改我的擅长",
								content:json.content,
								footer: true,
								header: true,
								border: true,
								innerPadding: true,
								backdrop: true,
								yes: function() {
									specialty=$('#ajax_edit_sp_input').val()
									$.getJSON(ajaxURL, { act: "ajax_edit_sp",specialty:specialty,edit:'1'}, function(json){
										if (json.status==0){
											disapperTooltip("remind", json.content);
										}else if (json.status==1){
 											disapperTooltip("success",json.content);
											$('.J_user_edit_sp').text(json.specialty);
										}else{
											disapperTooltip("remind","修改失败，未知错误");
										}
								});	
							}
						});
					}else{
						YTATADialog.hide();
						disapperTooltip("remind","未知错误");
					}
		});
	});
});
</script>
</body>
</html>
